<template>
  <div class="flex-grid">
    <div class="header hairlines-bottom">
      <i class="iconfont icon-return" @click="back"></i>
      <h3>我的丰期</h3>
      <router-link to="/mine/Installment">
        丰期记录
      </router-link>
    </div>
    <div class="flex-main">
      <div class="todo hairlines-bottom">
        <p class="title">待还款金额(元)</p>
        <p class="money">￥{{detail.repay_money || 0.00}}</p>
        <p class="tips" v-if="detail.repay_num !== 0">共<span>{{detail.repay_num}}笔</span>未还清</p>
      </div>
      <router-link :to="'/mine/aheadrepay'">
        <div class="repay iconfont icon-more">
          提前还款
        </div>
      </router-link>
      <div class="lists">
        <router-link :to="'/mine/bill/detail/' + list.user_loan_id" v-for="(list, index) in detail.result" :key="index" :class="index !== 0 ? 'hairlines-top' : ''">
          <p class="time">{{list.due_date}}<span v-if="list.statusName !== ''">{{list.statusName}}</span></p>
          <p class="money iconfont icon-more">本期应还<span>￥{{list.need_repay}}</span></p>
        </router-link>
      </div>
    </div>    
    <footer>
      <input class="footer-fullW-bt" type="button" value="返回" @click="back">
    </footer>
  </div>
</template>
<script>
  // 我的丰期
  export default {
    name: 'bill',
    data () {
      return {
        title: '我的丰期',
        beforehandLink: '/mine/repayList/:id'
      }
    },
    computed: {
      detail: function () {
        return this.$store.state.billDetail
      }
    },
    methods: {
      back () {
        this.$router.push('/mine')
      }
    },
    created () {
      this.setTitle(this.title)
      this.api.getBillDetail()
      this.api.getRepayList()
    }
  }
</script>
<style lang="scss" scoped>
  @function rem($px) {
    @return $px / 75 * 1rem;
  }
  .header{
    position: relative;
    background: #fff;
    padding: 0 rem(24);
    height: rem(90);
    line-height: rem(90);
    font-size: rem(26);
    color: #333;
    .iconfont{
      position: absolute;
      top: 0;
      left: rem(24);
      bottom: 0;
    }
    h3{
      font-size: rem(33);
      text-align: center;
    }
    a{
      position: absolute;
      top: 0;
      right: rem(24);
      bottom: 0;
      color: #333;
    }
  }
  .flex-main{
    .todo{
      background: #fff;
      text-align: center;
      padding: rem(35) 0 rem(40);
      .title{
        margin-bottom: rem(15);
        font-size: rem(30);
        color: #141414;
      }
      .money{
        margin-bottom: rem(15);
        font-size: rem(68);
        color: #ff8131;
      }
      .tips{
        font-size: rem(26);
        color: #999;
        span{
          color: #f81e1e;
        }
      }
    }
    .repay{
      margin-bottom: rem(15);
      background: #fff;
      position: relative;
      padding: 0 rem(24);
      height: rem(90);
      line-height: rem(90);
      font-size: rem(30);
      color: #333;
      &:before{
        position: absolute;
        top: 0;
        right: rem(24);
        bottom: 0;
        font-size: rem(22);
        color: #666;
      }
    }
    .lists{
      background: #fff;
      a{
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 rem(24);
        height: rem(120);
        font-size: rem(30);
        color: #141414;
        .time{
          span{
            margin-left: rem(5);
            color: #d01818;
          }
        }
        .money{
          position: relative;
          padding-right: rem(50);
          display: flex;
          align-items: center;
          font-size: rem(28);
          color: #808080;
          span{
            margin-left: rem(15);
          }
          i{
            font-size: rem(22);
            color: #666;
          }
        }
        .money:before{
          position: absolute;
          top: rem(6);
          right: 0;
          font-size: rem(22);
          color: #666;
        }
      }
    }
  }
  footer{
    height: rem(100);
  }
</style>
